<template>
  <div class="home">
    <el-container>
  <el-header>
    <div class="title_left">电商后台管理系统</div>
    <div class="title_right"><el-button>退出</el-button></div>
  </el-header>
  <el-container>
    <el-aside width="200px"
    :style="{width:isCollapse?'64px':'200px'}">
      <el-row class="tac">
  <el-col :span="24">
    <div class="home_fold" @click="isCollapse=!isCollapse"
    :style="{width:isCollapse?'64px':'200px',cursor:'pointer'}">|||</div>
    <el-menu
      :default-active="$route.path"
      class="el-menu-vertical-demo"
      background-color="#333744"
      text-color="#ffff"
      :router="true"
      :unique-opened="true"  
      @open="handleOpen"
      @close="handleClose"
      :collapse="isCollapse"
       >
      <el-submenu :index="item.path" v-for="item in list" :key="item.id" >
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>{{item.authName}}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item :index="it.path" v-for="it in item.children" :key="it.id">{{it.authName}}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </el-col>
      </el-row>
    </el-aside>
    <el-main>
      <!-- <div style="font-size: 25px;">welcome!</div> -->
      <router-view/>
    </el-main>
  </el-container>
</el-container>
  </div>
</template>
<script>
import { menus } from "../until/http";
export default {

  data () {
    return {
      list:[],
      isCollapse:false
    }
  },

  mounted () {
     this.setlist()
  },

  methods: {
    // 菜单栏数据请求
    async setlist(){
        const {data:res}=await menus()
        console.log(res)
        this.list=res.data
        console.log(this.list)
    },
    handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      }
  }
}
</script>
<style  scoped>
/* .home{
  width: 100vw;
  height: 100vh;
} */
.el-header{
position: relative;
}
.title_left{
   color: #ffff;
   font-size: 20px;
   position: absolute;
   top: 50%;
   left: 300px;
   transform: translate(-50%,-50%)
}
.home_fold{
  padding: 10px 0;
  background-color: #4a5064;
  color: #ffff;
}
.title_right{
  color: #ffff;
  position: absolute;
   top: 50%;
   right: 20px;
   transform: translate(0,-50%)
}
.el-header, .el-footer {
  background-color: #373d41;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  .el-aside {
    background-color: #333744;
    color: #333;
    text-align: center;
    /* line-height: 200px; */
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    /* text-align: center; */
    /* line-height: 160px; */
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  .el-container{
    width: 100vw;
    height: 100vh;
    box-sizing:border-box;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>
